#region Copyright
/// <copyright>
/// Copyright (c) 2007 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#endregion

using System;
using System.Collections.Generic;
using System.Text;

namespace Osh.Teletext
{
	public class PacketX281 : EnhancementDataPacket
	{
		private Charset _defaultCharset;
		private Charset _secondCharset;

		public PacketX281(int magazine, int packet, byte[] data, int position)
			: base(magazine, packet, data, position)
		{
			int triplet1 = this.GetTriplet(0);

			if((triplet1 & 0x20203) == 0)	// Bits 0,1,9,17 has to be set to 0 to indicate a Level 1 compatibility packet
			{
				_defaultCharset = new Charset((byte)((triplet1 >> 2) & 0x7F));
				_secondCharset = new Charset((byte)((triplet1 >> 10) & 0x7F));
			}
			else
			{
				_defaultCharset = Charset.Empty;
				_secondCharset = Charset.Empty;
			}
		}

		public Charset DefaultCharset
		{
			get { return _defaultCharset; }
		}

		public Charset SecondCharset
		{
			get { return _secondCharset; }
		}
	}
}
